<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<script>
        $(function(){
           $(".saveButton").click(function(){

               var bootstrapValidator = form.data('bootstrapValidator');
               //手动触发验证
               bootstrapValidator.validate();
               if(bootstrapValidator.isValid()){
                   //表单提交的方法、比如ajax提交
               }
           }) ;
        });
         $("form").bootstrapValidator({
            message: "This value is not valid",

            feedbackIcons: {    // 输入框不同状态，显示图片的样式*
                valid: "glyphicon glyphicon-ok",
                invalid: "glyphicon glyphicon-remove",
                validating: "glyphicon glyphicon-refresh"
            },

            fields: {   // 验证

                name: {
                    message: "校区名称验证失败",
                    validators: {
                        notEmpty: {
                            message: "校区名称不能为空"
                        },

                        regexp: {
                            regexp: /([\u4E00-\uFA29]|[\uE7C7-\uE7F3]|[a-zA-Z0-9_]){1,10}$/,
                            message: "校区名称只能包含汉字,英文大小写、数字和下划线"
                        }
                    }
                },
                note:{
                    message:"备注校验失败",
                    validators: {
                        notEmpty: {
                            message: "校区名称不能为空"
                        }
                    },
                }
            }
        });
</script>

 <form action="/enrollandpay/campus/save" class="form-horizontal" id="campusForm">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">学校信息</h4>
                </div>

                <div class="modal-body">
                    <!--
                     -->
                    <div class="form-group">
                        <input type="hidden" name="id" value="${thisCampus.id}">
                        <input type="hidden" name="token" value="${token}">
                        <label class="col-sm-2 control-label" for="name">校区名称</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="请输入备注" name="name" id="name"
                                   value="${thisCampus.name}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="note">备注</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="请输入备注" name="note" id="note"
                                   value="${thisCampus.note}"/>
                        </div>
                    </div>

                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" id="dismissCampus" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary saveButton" onclick="doSave('campus')"> 保存</button>
                </div>
            </form>
